//
//  WWLeftTableViewCell.m
//  Shopping
//
//  Created by 张德华 on 8/20/16.
//  Copyright © 2016 张湾湾. All rights reserved.
//

#import "WWLeftTableViewCell.h"
#import "WWLeftCellModel.h"
@interface WWLeftTableViewCell()

/**做变黄色图片*/
@property (nonatomic,strong) UIImageView *iv_imageView;
/**分类名称*/
@property (nonatomic,strong) UILabel *lb_nameLabel;
/**作为分隔线*/
@property (nonatomic,strong) UIView *v_separaterView;



@end

@implementation WWLeftTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        
        [self setupUI];
    }
    return self;
}

#pragma mark
#pragma mark - ***************初始化界面
- (void)setupUI {
    
    //------ 添加控件
    [self addSubview:self.lb_nameLabel];
    [self addSubview:self.v_separaterView];
    [self addSubview:self.iv_imageView];
    
    //------ 控件约束
    [self.lb_nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.leading.equalTo(self).offset(10);
    }];
    
    [self.v_separaterView makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.equalTo(0);
        make.height.equalTo(0.4);
    }];
    
    
    [self.iv_imageView makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self);
        make.top.width.equalTo(5);
        make.bottom.equalTo(-5);
    }];
    
    self.iv_imageView.hidden = YES;
}

#pragma mark
#pragma mark - ***************设置数据
- (void)setModel:(WWLeftCellModel *)model {
    _model = model;
    self.lb_nameLabel.text = model.name;
}

- (void)setSelected:(BOOL)selected
           animated:(BOOL)animated{
    
    self.iv_imageView.hidden = !selected;
    self.contentView.backgroundColor = !selected ? [UIColor colorWithRed:(235)/256.0 green:(235)/256.0 blue:(235)/256.0 alpha:1.0] : [UIColor whiteColor];
}


#pragma mark
#pragma mark - ***************懒加载
- (UILabel *)lb_nameLabel {
    if (!_lb_nameLabel) {
        _lb_nameLabel = [[UILabel alloc] init];
        _lb_nameLabel.font = [UIFont systemFontOfSize:16];
        [_lb_nameLabel sizeToFit];
    }
    return _lb_nameLabel;
}

- (UIView *)v_separaterView {
    if (!_v_separaterView) {
        _v_separaterView = [[UIView alloc] init];
        _v_separaterView.backgroundColor = [UIColor colorWithRed:(218)/256.0 green:(218)/256.0 blue:(218)/256.0 alpha:1.0];
    }
    return _v_separaterView;
}

- (UIImageView *)iv_imageView {
    if (!_iv_imageView) {
        _iv_imageView = [[UIImageView alloc] init];
        _iv_imageView.image = [UIImage imageNamed:@"v2_coupon_verify_normal"];
    }
    return _iv_imageView;
}





@end
